<?php
namespace app\controller;

use app\BaseController;
use think\facade\Session;
use think\facade\View;

class Index extends BaseController
{
    public function index()
    {
        // 获取当前登录用户信息
        $userId = Session::get('user_id');
        $username = Session::get('username');
        
        // return json([
        //     'code' => 200,
        //     'msg' => '欢迎访问首页',
        //     'data' => [
        //         'user_id' => $userId,
        //         'username' => $username,
        //         'message' => '这是一个需要登录验证的页面'
        //     ]
        // ]);
        return view();
    }

    public function hello($name = 'ThinkPHP8')
    {
        return json([
            'code' => 200,
            'msg' => 'Hello ' . $name,
            'data' => [
                'user_id' => Session::get('user_id'),
                'username' => Session::get('username')
            ]
        ]);
    }
}
